#ifndef __AFE_H_
#define __AFE_H_

#include "stdint.h"


#define GP1					(0x10)
#define GP2					(0x20)
#define GP3					(0x30)
#define GP4					(0x40)
#define GP5					(0x50)
#define GP6					(0x60)

//#define GP1_OFF				(GP1 | 0)
//#define GP1_NTC_INPUT		(GP1 | 1)
//#define GP1_ANALOG_INPUT	(GP1 | 2)
//#define GP1_CHG_CONTROL		(GP1 | 3)
//#define GP2_OFF				(GP2 | 0)
//#define GP2_NTC_INPUT		(GP2 | 1)
//#define GP2_ANALOG_INPUT	(GP2 | 2)
//#define GP2_INTERRUPT		(GP2 | 6)
//#define GP2_L_PDSG_CONTROL	(GP2 | 7)
//#define GP3_OFF				(GP3 | 0)
//#define GP3_NTC_INPUT		(GP3 | 1)
//#define GP3_ANALOG_INPUT	(GP3 | 2)
//#define GP3_INTERRUPT		(GP3 | 6)
//#define GP3_L_PCHG_CONTROL	(GP3 | 7)
//#define GP4_OFF				(GP4 | 0)
//#define GP4_NTC_INPUT		(GP4 | 1)
//#define GP4_ANALOG_INPUT	(GP4 | 2)
//#define GP4_DSG_CONTROL		(GP4 | 3)
//#define GP5_OFF				(GP5 | 0)
//#define GP5_NTC_INPUT		(GP5 | 1)
//#define GP5_ANALOG_INPUT	(GP5 | 2)
//#define GP5_INTERRUPT		(GP5 | 6)
//#define GP5_L_CHG_CONTROL	(GP5 | 7)
//#define GP6_OFF				(GP6 | 0)
//#define GP6_NTC_INPUT		(GP6 | 1)
//#define GP6_ANALOG_INPUT	(GP6 | 2)
//#define GP6_INTERRUPT		(GP6 | 6)
//#define GP6_L_DSG_CONTROL	(GP6 | 7)

typedef enum
{
	GP1_OFF				= 0 << 6,
	GP1_NTC_INPUT		= 1 << 6,
	GP1_ANALOG_INPUT	= 2 << 6,
	GP1_CHG_CONTROL		= 3 << 6,
	
	GP2_OFF				= 0 << 3,
	GP2_NTC_INPUT		= 1 << 3,
	GP2_ANALOG_INPUT	= 2 << 3,
	GP2_INTERRUPT		= 6 << 3,
	GP2_L_PDSG_CONTROL	= 7 << 3,
	
	GP3_OFF				= 0 << 0,
	GP3_NTC_INPUT		= 1 << 0,
	GP3_ANALOG_INPUT	= 2 << 0,
	GP3_INTERRUPT		= 6 << 0,
	GP3_L_PCHG_CONTROL	= 7 << 0,
	
	GP4_OFF				= 0 << 6,
	GP4_NTC_INPUT		= 1 << 6,
	GP4_ANALOG_INPUT	= 2 << 6,
	GP4_DSG_CONTROL		= 3 << 6,
	
	GP5_OFF				= 0 << 3,
	GP5_NTC_INPUT		= 1 << 3,
	GP5_ANALOG_INPUT	= 2 << 3,
	GP5_INTERRUPT		= 6 << 3,
	GP5_L_CHG_CONTROL	= 7 << 3,
	
	GP6_OFF				= 0 << 0,
	GP6_NTC_INPUT		= 1 << 0,
	GP6_ANALOG_INPUT	= 2 << 0,
	GP6_INTERRUPT		= 6 << 0,
	GP6_L_DSG_CONTROL	= 7 << 0,
	
	__GPX_END = 0xFF,
}_gpx_enum;


void afe_set_cell_number(uint8_t number);
void afe_set_cell_ov_protect(uint16_t volt);
void afe_set_cell_uv_protect(uint16_t volt);
void afe_set_pack_ov_protect(uint16_t volt);
void afe_set_pack_uv_protect(uint16_t volt);
void afe_set_doc1_protect(uint32_t value,uint16_t delay);
void afe_set_doc2_protect(uint32_t value,uint16_t delay);
void afe_set_coc1_protect(uint32_t value,uint16_t delay);
void afe_set_coc2_protect(uint32_t value,uint16_t delay);
void afe_set_sc_protect(uint32_t value,uint16_t delay);
void afe_set_cb_number(uint32_t number);
void afe_set_dsg_mos(uint8_t status);
void afe_set_chg_mos(uint8_t status);
void afe_set_gpx1_3_config(_gpx_enum gpx_config);
void afe_set_gpx4_6_config(_gpx_enum gpx_config);

uint16_t afe_read_cell_volt(uint8_t i_cell_num);
uint16_t afe_read_vtop_volt(void);
uint16_t afe_read_pack_volt(void);
uint16_t afe_read_load_volt(void);
uint16_t afe_read_v1p8_volt(void);
uint16_t afe_read_vgpx_volt(uint8_t i_gpx_num);
uint32_t afe_read_pack_current(void);
uint32_t afe_read_pack_current2(void);
int16_t  afe_read_inter_temp(void);
void 	 afe_read_system_status(uint32_t* o_status1,uint32_t* o_status2);

#endif


